package com.controller;

import com.pojo.User;
import com.service.impl.AdminServiceImpl;
import com.service.impl.DoctorServiceImpl;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.util.Map;

@RestController
@RequestMapping("/User")
public class UserController {
    @Resource
    private AdminServiceImpl adminServiceImpl;

    @Resource
    private DoctorServiceImpl doctorServiceImpl;

    //登录判断
    @RequestMapping("/login")
    public Map<String, Object> login(@RequestBody User user, HttpServletRequest request) {
        if (user.getRole().equals("管理员")) {
            return this.adminServiceImpl.login(user, request);
        }
        return this.doctorServiceImpl.login(user, request);
    }
}
